<%@ Page Language="C#" MasterPageFile="~/Admin.master" AutoEventWireup="true"
    CodeFile="ApprovedUser.aspx.cs" Inherits="ApprovedUser" Title="User Approval " %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        function SetChangeValue(objHidden) {
            objHidden.value = "true";
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <center>
        <br />
        <div class="HeadingFormatDefault Heading" style="width: 80%;">
            Search Users
        </div>
    </center>
    <br />
    <br />
    <table width="100%">
        <tr>
            <td class="formContainer">
                <center>
                    <table border="0" cellpadding="6" cellspacing="0" style="border-collapse: collapse;">
                        <tr>
                            <td class="formLabel">
                                User Type
                            </td>
                            <td class="formValue">
                                <asp:DropDownList ID="ddUserType" runat="server" DataSourceID="UertypeDataSource1"
                                    DataTextField="UserType" DataValueField="UserTypeId" OnDataBound="ddUserType_DataBound">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="UertypeDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                    SelectCommand="SELECT [UserTypeId], [UserType] FROM [tblUserType]"></asp:SqlDataSource>
                            </td>
                        </tr>
                        <tr>
                            <td class="formLabel">
                                First Name
                            </td>
                            <td class="formValue">
                                <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
                            </td>
                            <td class="formLabel">
                                Status
                            </td>
                            <td class="formValue">
                                <asp:DropDownList ID="DropDownList1" runat="server">
                                    <asp:ListItem Value="2">All</asp:ListItem>
                                    <asp:ListItem Value="1">Approved</asp:ListItem>
                                    <asp:ListItem Value="0">Dis Approved</asp:ListItem>
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td class="formLabel">
                                E-Email
                            </td>
                            <td class="formValue">
                                <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                            </td>
                            <td class="formLabel">
                                Last Name
                            </td>
                            <td class="formValue">
                                <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:CheckBox ID="chkDenied" runat="server" Text="Show all denied records " Checked="false" />
                            </td>
                            <td colspan="2" style="text-align: right;">
                                <asp:Button ID="btnGenrateReport" runat="server" OnClick="LoginButton_Click" Text="Generate Reports" />
                                &nbsp;<asp:Button ID="Reset" OnClientClick="javascript:this.form.reset();return false;"
                                    runat="server" Text="Reset" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4">
                                &nbsp;
                            </td>
                        </tr>
                    </table>
                </center>
            </td>
        </tr>
        <tr>
            <td>
                <asp:GridView ID="GridView1" runat="server" HorizontalAlign="Center" AutoGenerateColumns="False"
                    AllowPaging="True" Width="100%" AllowSorting="True" DataKeyNames="UserId" OnRowDataBound="GridView1_RowDataBound"
                    OnSelectedIndexChanging="GridView1_SelectedIndexChanging" OnSorting="GridView1_Sorting">
                    <Columns>
                        <asp:TemplateField HeaderText="S.No">
                            <ItemTemplate>
                                <asp:Label ID="lblId" runat="server" Text=' <%# Container.DataItemIndex + 1 %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField ItemStyle-HorizontalAlign="Center" DataField="Username" HeaderText="Username"
                            ReadOnly="true">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField ItemStyle-HorizontalAlign="Center" DataField="FirstName" HeaderText="FirstName">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField ItemStyle-HorizontalAlign="Center" DataField="LastName" HeaderText="LastName">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField ItemStyle-HorizontalAlign="Center" DataField="Email" HeaderText="Email">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField ItemStyle-HorizontalAlign="Center" DataField="CreatedDate" HeaderText="Created Date"
                            DataFormatString="{0:D}">
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:TemplateField AccessibleHeaderText="Role" HeaderText="Role">
                            <ItemTemplate>
                                <asp:DropDownList ID="ddUserType" runat="server" DataSourceID="UertypeDataSource1"
                                    DataTextField="UserType" DataValueField="UserTypeId">
                                </asp:DropDownList>
                                <asp:HiddenField ID="UserTypeId" runat="server" Value='<%# Convert.ToString(DataBinder.Eval (Container.DataItem, "UserTypeId")).Trim()%>' />
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField AccessibleHeaderText="Approved" HeaderText="Is Approved">
                            <ItemTemplate>
                                <asp:HiddenField ID="UserId" runat="server" Value='<%# Convert.ToString(DataBinder.Eval (Container.DataItem, "UserId")).Trim()%>' />
                                <asp:HiddenField ID="ChangedOrNo" runat="server" Value="false" />
                                <asp:CheckBox ID="ChkApproved" runat="server" Checked='<%# Convert.ToString(DataBinder.Eval (Container.DataItem, "IsApproved")).Trim()=="True" ? true : false %>' />
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField AccessibleHeaderText="Approved">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkDyned" runat="server" CommandName='<%# chkDenied.Checked == false ? "Denied" : "Accepted"%>'
                                    CommandArgument='<%# Convert.ToString(DataBinder.Eval (Container.DataItem, "UserId")).Trim()%>'
                                    OnCommand="lnkDyned_Command">
                                        <%= chkDenied.Checked == false ? "Denied" : "Accepted"%></asp:LinkButton>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField AccessibleHeaderText="Approved">
                            <ItemTemplate>
                                <asp:HyperLink ID="lnkEdit" runat="server" NavigateUrl='<%# "MyProfile.aspx?UserId=" + Eval("UserId")%>'
                                    Text="Edit" />
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        No Record Found
                    </EmptyDataTemplate>
                </asp:GridView>
                <asp:SqlDataSource ID="ListDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                    SelectCommand="spUserFilter" SelectCommandType="StoredProcedure">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ddUserType" DefaultValue="0" Name="UserType" PropertyName="SelectedValue"
                            Type="Int32" />
                        <asp:ControlParameter ControlID="txtFirstName" DefaultValue=" " Name="FirstName"
                            PropertyName="Text" Type="String" />
                        <asp:ControlParameter ControlID="txtLastName" DefaultValue=" " Name="LastName" PropertyName="Text"
                            Type="String" />
                        <asp:ControlParameter ControlID="DropDownList1" DefaultValue="2" Name="isApproved"
                            PropertyName="SelectedValue" Type="Byte" />
                        <asp:ControlParameter ControlID="txtEmail" DefaultValue=" " Name="Email" PropertyName="Text"
                            Type="String" />
                        <asp:ControlParameter ControlID="chkDenied" DefaultValue="true" Name="isDenied" PropertyName="Checked"
                            Type="Boolean" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
                <br />
                <div style="text-align: right; padding-right: 10px;">
                    <asp:Label ID="MessageLebal" runat="server" Text=""></asp:Label>
                    <asp:Button ID="btnUpdateRecord" EnableTheming="false" runat="server" Text="Update Status"
                        OnClick="btnUpdateRecord_Click" />
                </div>
            </td>
        </tr>
    </table>
    <%-- <asp:UpdatePanel ID="updRights" runat="server" UpdateMode="Conditional">
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="GridView1" EventName="SelectedIndexChanging" />
                    </Triggers>
                    <ContentTemplate>
                        <asp:Panel ID="pnlRights" runat="server" Visible="false">
                            <asp:Label ID="lblName" runat="server"></asp:Label>
                            <asp:HiddenField ID="hdUserId" runat="server" Value="" />
                            <asp:GridView ID="gvRights" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                DataSourceID="UserRightDataSource" OnRowDataBound="gvRights_RowDataBound">
                                <Columns>
                                    <asp:BoundField DataField="PageName" HeaderText="PageName" SortExpression="PageName" />
                                    <asp:BoundField DataField="PageURL" HeaderText="PageURL" SortExpression="PageURL" />
                                    <asp:TemplateField AccessibleHeaderText="Approved" HeaderText="Status">
                                        <ItemTemplate>
                                            <asp:HiddenField ID="PageID" runat="server" Value='<%# Convert.ToString(DataBinder.Eval (Container.DataItem, "PageId"))%>' />
                                            <asp:HiddenField ID="ChangedOrNo" runat="server" Value="false" />
                                            <asp:CheckBox ID="ChkApproved" runat="server" Checked='<%# Convert.ToString(DataBinder.Eval (Container.DataItem, "isRights")).Trim()=="1" ? true : false %>' />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <EmptyDataTemplate>
                                    No Record Found
                                </EmptyDataTemplate>
                            </asp:GridView>
                            <asp:SqlDataSource ID="UserRightDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                SelectCommand="spGetUserRightsByUserId" SelectCommandType="StoredProcedure">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="hdUserId" DefaultValue="0" Name="UserId" PropertyName="Value"
                                        Type="Int32" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                            <asp:Button ID="btnGiveRights" runat="server" Text="Rights" OnClick="btnGiveRights_Click" />
                        </asp:Panel>
                    </ContentTemplate>
                </asp:UpdatePanel>--%>
</asp:Content>
